package cn.huapu.power.energy.service.impl;

import cn.huapu.power.energy.bean.SysClient;
import cn.huapu.power.energy.bean.vo.PcmUsepowerunitVo;
import cn.huapu.power.energy.bean.vo.SysClientVo;
import cn.huapu.power.energy.mapper.SysClientMapper;
import cn.huapu.power.energy.service.SysClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 测试用户权限服务实现类
 * @author autogen
 *
 */
@Service
public class SysClientServiceImpl extends BaseServiceImpl<SysClientMapper, SysClient,Integer> implements SysClientService {

    @Override
    @Transactional(readOnly = true)
    public SysClientVo getByids(String name,Integer clientid) {
        SysClientVo node  = mapper.getreeNode(clientid);
        List<SysClientVo> childTreeNodes  = mapper.queryTreeNode(name,clientid);
        for(SysClientVo child : childTreeNodes){
            SysClientVo n = getByids(name,child.getId());
            node.getNodes().add(n);
        }
        return node;
    }

    @Override
    @Transactional(readOnly = true)
    public List<SysClientVo> getAllIds(String name) {
        List<SysClientVo> list = mapper.getAllIds(name);
        return list;
    }
}
